<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="pragram" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>快递查询</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link href="/Public/phone/css/swiper-3.0.8.css" rel="stylesheet" type="text/css">
    <link href="/Public/phone/css/iconfont.css" rel="stylesheet" type="text/css">
    <link href="/Public/phone/css/style.css" rel="stylesheet" type="text/css">
    <script src="/Public/phone/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/layer/layer.js"></script>
    <script src="/Public/phone/js/swiper.min-3.1.0.js"></script>
</head>   
<body>
<div class="nav">
	<a href="javascript:;" class="active">查询快递</a>
	<a href="<?php echo U('Form/index');?>">录入信息</a>
</div>
<div class="contain">
	<span class="middleSpan"></span>
	<div class="middleDiv">
		<img src="/Public/phone/images/head.png">
		<div class="middleDiv">
			<div class="formList flexBox">
				<i class="iconfont icon-shouji"></i>
				<input class="flexChild" id="phone" type="tel" maxlength="11" placeholder="请输入收件人手机号" />
				<button class="wangyao_button"  id="luyin" >语音输入</button>
			</div>
			<div class="formList flexBox">
				<i class="iconfont icon-bianhaochaxun"></i>
				<input class="flexChild" type="text" id="no" placeholder="请输入快递编号"/>
				<button class="saomiao">扫码查询</button>
			</div>
		
			<button class="formList" onclick="check($('#phone').val(),$('#no').val())">查询</button>
		</div>
	</div>
	
</div>

<div id="huatong" style="display:none;position:fixed;z-index:99999;bottom:0px;left:0px;background:rgba(0,0,0,0.5);width:100%;text-align:center;height:5rem">
<img src="/Public/phone/images/huatong.gif" style="height:5rem;width:100%" />
</div>

<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	wx.config({
		debug:false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		appId: '<?php echo ($signPackage["appId"]); ?>', // 必填，公众号的唯一标识
		timestamp:<?php echo ($signPackage["timestamp"]); ?>, // 必填，生成签名的时间戳
		nonceStr: '<?php echo ($signPackage["nonceStr"]); ?>', // 必填，生成签名的随机串
		signature: '<?php echo ($signPackage["signature"]); ?>',// 必填，签名，见附录1
		jsApiList: ['scanQRCode','startRecord','stopRecord','onVoiceRecordEnd','translateVoice'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
	});
	$(".saomiao").click(function(){
		wx.scanQRCode({
		needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
		scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
		success: function (res) {
			var result = res.resultStr.split(','); // 当needResult 为 1 时，扫码返回的结果
			$("#no").val(result[1]);
			}
		});
	});
	function check(phone,no){
		// if(phone){
		// 	if(!(/^1[34578]\d{9}$/.test(phone))){
		// 		layer.msg("请输入正确的收件人手机号",{time:1500});
		// 		return false;
		// 	};
		// }
		if(!phone&&!no){
			layer.msg("请至少输入一个查询信息",{time:1500});
			return false;
		}
		window.location.href="<?php echo U('List/index');?>?phone="+phone+"&&no="+no;
	}
	
	
	
	document.getElementById('luyin').addEventListener("touchstart",function(event){
		event.preventDefault();
		$("#huatong").show();
		wx.startRecord();		
	});
	
	document.getElementById('luyin').addEventListener("touchend",function(event){
		 event.preventDefault();
		 $("#huatong").hide();
		 	wx.stopRecord({
    success: function (res) {
        var localId = res.localId;
		wx.translateVoice({
		localId: localId, // 需要识别的音频的本地Id，由录音相关接口获得
		isShowProgressTips: 1, // 默认为1，显示进度提示
		success: function (res) {
		var result = res.translateResult;
		if(result){
		$("#phone").val(result.substring(0,result.length-1));	
		}else{
		$("#phone").val('未识别到语音输入');
		}	
    }
});
    }
});
	});
</script>
</body>
</html>